<?php
header("Content-Type: text/html; charset=utf-8"); 
require_once('sessionVal.php');

require("../config.inc.php");
require_once(COMM_PATH."BMS.php");
require_once(COMM_PATH."paging.php");

$bms = new BMS();
$pages = 1;//当前页码
$username = "";//分类名称

if ($_SERVER['REQUEST_METHOD']=='POST'){
	if ($_POST['CURRENTPAGE']!=null && $_POST['CURRENTPAGE']!=""){
		$pages = $_POST['CURRENTPAGE'];
	}
	if ($_POST['C_NAME']!=null && $_POST['C_NAME']!=""){
		$username = $_POST['C_NAME'];
	}
}
$wordList = $bms->getLeaveWordForPage($pages,$username);
$totality = $bms->getLeaveWordNum($username);
$_PAGE = new PageInfo($pages, $totality);


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
	<title>留言管理</title>
	<link rel="stylesheet" href="../resources/css/admin/style.css" />
	<script src="../resources/js/jquerys/lib/jquery.js" type="text/javascript"></script>
	<script src="../resources/js/jquerys/lib/jquery.cookie.js" type="text/javascript"></script>
	<script type="text/javascript" src="../resources/js/util.js"></script>
<?php 
	echo '<script type="text/javascript"> var uppage = "'.$_PAGE->_uppage.'";var nextpage = "'.$_PAGE->_nextpage.'";var endpage = "'.$_PAGE->_totalityPage.'"; </script>';
?>
	<script type="text/javascript">
	 	$(document).ready(function(){
	 		$('#user-search-input,#current_page').keydown(function(e){
	 			if(e.keyCode==13){
		 			$("#form_word").submit();
	 			}
	 		});
	 		$("#toFirst").click(function(){
				$("#current_page").val("1");
				$("#form_word").submit();
		 	});
	 		$("#up").click(function(){
	 			$("#current_page").val(uppage);
				$("#form_word").submit();
		 	});
	 		$("#down").click(function(){
	 			$("#current_page").val(nextpage);
				$("#form_word").submit();
		 	});
	 		$("#toEnd").click(function(){
	 			$("#current_page").val(endpage);
				$("#form_word").submit();
		 	});

		 	$("a.showC").mouseover(function(e){
				this.myTitle = this.title;
				this.title = "";	
				var tooltip = "<div id='showContent'>"+ this.myTitle +"</div>"; //创建 div 元素
				$("body").append(tooltip);	//把它追加到文档中
				$("#showContent").css({
						"top": (e.pageY+20) + "px",
						"left": (e.pageX-400)  + "px"
					}).show("600");	  //设置x坐标和y坐标，并且显示
			}).mouseout(function(){		
				this.title = this.myTitle;
				$("#showContent").remove();   //移除 
			});

			
		});
 
	</script>
	</head>
	<body>
	<div id="wrap">
		<div id="adminmenuback"></div>
		<div id="menu">
			<h3 class="menutop">控制台</h3>
			<?php require('menus.php');?>
		</div>
		<div id="main-content">
			<?php require('top.php');?>
          	  
          	<div id="wpcontent">
          		
          	    <h2>留言列表</h2>
          	    <div id="mainform">
          	    	<form action="" method="post" name="form_word" id="form_word">
          	    		<p class="searchbox">
          	    			<input type="text" id="user-search-input" name="C_NAME" value="<?php echo $username?>"/>
                        	<input type="submit" name="sb" id="search-submit" class="button" value="搜索留言"/>
          	    		</p>
          	    		<table cellspacing="0" border="1" id="table_1" class="table_1">
						 	<caption> </caption> 
						 		<tr >
						 			<th scope="col" width="8%">序号</th>
						 			<th scope="col" width="20%">留言用户</th>
						 			<th scope="col" width="20%">EMAIL</th>
						 			<th scope="col" width="24%">时间</th>
						 			<th scope="col" width="28%">操作</th>
						 		</tr>
          	    		
          	    			<?php if ($wordList){
 										foreach ($wordList as $key => $value){?>
          	    				<tr>
          	    					<td class="row" align="left"><input type="checkbox" value="<?php echo $value['BID']?>"/></td>
          	    					<td class="row" align="left"><?php echo $value['username']?></td>
          	    					<td class="row" align="left"><?php echo $value['email']?></td>
          	    					<td class="row" align="left"><?php echo $value['createTime']?></td>
          	    					<td class="row" align="left"><?php echo "<a href=\"javascript:confirmTool('leavewordDel.php?F_ID=$value[BID]','确认删除留言？')\">[删除]</a>
 										<a href=\"javascript:;\" class=\"showC\" title=\"$value[contents]\">[查看留言]</a>";
 									?>
 									</td>
          	    				</tr>
          	    				<?php }
          	    				}
          	    				?>
          	    				<tr>
          	    					<td class="row" align="right" colspan="5">
          	    						共<?php echo $_PAGE->_totality?>项，
          	    						<input type="button" name="toFirst" id="toFirst" value="&lt;&lt;"  <?php if ($_PAGE->_isFirst){?>disabled="disabled" class="disabledbutton"<?php }else {?> class="button" <?php }?>/>
          	    						<input type="button" name="up" id="up" value="&lt;" <?php if ($_PAGE->_isFirst){?>disabled="disabled" class="disabledbutton"<?php }else {?> class="button" <?php }?>/>
          	    						&nbsp;&nbsp;当前
          	    						<input type="text" id="current_page" name="CURRENTPAGE" size="1" value="<?php echo $_PAGE->_pageNum?>"/>
          	    						页，总共<?php echo $_PAGE->_totalityPage?>页&nbsp;&nbsp;
          	    						<input type="button" name="down" id="down"  value="&gt;" <?php if ($_PAGE->_isEnd){?>disabled="disabled" class="disabledbutton"<?php }else {?> class="button" <?php }?>/>
          	    						<input type="button" name="toEnd" id="toEnd"  value="&gt;&gt;" <?php if ($_PAGE->_isEnd){?>disabled="disabled" class="disabledbutton"<?php }else {?> class="button" <?php }?>/>
          	    					</td>
          	    				</tr>
          	    		</table>
          	    	</form>
          	    </div>
          	</div>
          	  
		</div>
 	</div>
 	
</body>
</html>

